import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

public class AlgorithmsDemo {

	public static void main(String[] args) {
		// will not work with int[]
		Integer[] data = { 1, 3, 4, 2, 6, 4, 11, 2 };

		List<Integer> list = new ArrayList<Integer>(Arrays.asList(data));
		System.out.println(list);

		Collections.sort(list);
		System.out.println("Sorted: " + list);

		int pos = Collections.binarySearch(list, 6);
		System.out.println("The position of 3 is " + pos);

		System.out.println("SubList from 0 to 3 index" + list.subList(0, 3));
		// remove first element from sub list
		list.subList(0, 3).remove(0);
		System.out.println("W/o first element?: " + list);

		Collections.reverse(list.subList(0, 3));
		System.out.println("First 3 elements reversed: " + list);

		Collections.shuffle(list);
		System.out.println("Shuffled: " + list);

		Collections.swap(list, 0, 1);
		System.out.println("First 2 elements swapped: " + list);

		System.out.println("maximal: " + Collections.max(list));

		// something else?

	}
}
